
	$(function(){
		$.post("../json/smileAction_smileData",{"smile.min":1,"smile.max":20},function(data){
			var str="";
			$.each(data.rows,function(index,item){
				if(data.gid!=null){
					id=data.gid; //获取用户点赞过的图片id  1101,1102
					var temp=id.split(","); //把id分隔开
					
					str+='<li><img id='+item.sid+' src="../'+item.saddr+'" /><div id="smile_zan" class="smile_zan">';
					str+='<div id="smile_zan_di" class="smile_zan_di"></div><div id="smile_zan_zan" class="smile_zan_zan">';
					
					
					if(id.indexOf(item.sid)!=-1){
						str+='<img id='+item.sid+' src="images/like.ico"  />';
					}else{
						str+='<img id='+item.sid+' src="images/no_like.ico"  />';
					}
					str+='<a href="javascript:sdetails('+item.sid+')"><p>'+item.sname+'</p></a>';	
					str+='</div></div></li>';
				}else{
					str+='<li><img id='+item.sid+' src="../'+item.saddr+'" /><div id="smile_zan" class="smile_zan">';
					str+='<div id="smile_zan_di" class="smile_zan_di"></div><div id="smile_zan_zan" class="smile_zan_zan">';
					str+='<img id='+item.sid+' src="images/no_like.ico"  />';
					str+='<a href="javascript:sdetails('+item.sid+')"><p>'+item.sname+'</p></a>';	
					str+='</div></div></li>';
				}
			});
			$(".smile_content_content ul").html(str);
			
			//取分页
			var obj=data.obj;
			str1="<span>&nbsp&nbsp"+obj.pageNo+"&nbsp&nbsp</span>";
			str2="<span>&nbsp共&nbsp"+obj.totalPage+"&nbsp页 &nbsp</span>";
			$("#spage1").html("");
			$("#spage2").html("");
			$(str1).appendTo( $("#spage1"));
			$(str2).appendTo( $("#spage2"));
			
			s_show();
		},"json");
		
		
		//点击拍照上传时,判断有没登录,没有登录弹出登录框
		$(".smile_content_nav_photo").bind({
			click:function(){
				var user=$("#currentUser").val();
				if( user==null || user=="" ){
					$(".log_user").css("display","block");
					$(".log_user_info").css("display","block");
				}else {
					location.href="smile_photo.jsp";
				}
			}
		});
		s_close();
	});
	
	//我的微笑页面请求
	function mysmile(){
		$("#s_liNo").val("my");
		
		var uid=$("#currentUser").val();
		
		if( uid==null || uid=="" ){
			$(".log_user").css("display","block");
			$(".log_user_info").css("display","block");
		}else{
			var str="";
			$.post("../json/smileAction_mySmile",{"smile.w_uid":uid,"smile.min":1,"smile.max":20},function(data){
				$.each(data.rows,function(index,item){
					if(data.gid!=null){
						id=data.gid; //获取用户点赞过的图片id  1101,1102
						var temp=id.split(","); //把id分隔开
						
						str+='<li><img id='+item.sid+' src="../'+item.saddr+'" /><div id="smile_zan" class="smile_zan">';
						str+='<div id="smile_zan_di" class="smile_zan_di"></div><div id="smile_zan_zan" class="smile_zan_zan">';
						
						
						if(id.indexOf(item.sid)!=-1){
							str+='<img id='+item.sid+' src="images/like.ico"  />';
						}else{
							str+='<img id='+item.sid+' src="images/no_like.ico"  />';
						}
						str+='<a href="javascript:sdetails('+item.sid+')"><p>'+item.sname+'</p></a>';	
						str+='</div></div></li>';
					}else{
						str+='<li><img id='+item.sid+' src="../'+item.saddr+'" /><div id="smile_zan" class="smile_zan">';
						str+='<div id="smile_zan_di" class="smile_zan_di"></div><div id="smile_zan_zan" class="smile_zan_zan">';
						str+='<img id='+item.sid+' src="images/no_like.ico"  />';
						str+='<a href="javascript:sdetails('+item.sid+')"><p>'+item.sname+'</p></a>';	
						str+='</div></div></li>';
					}
				});
				$(".smile_content_content ul").html(str);
				
				//取分页
				//var obj=data.pageInfo;
				//str1="<span>&nbsp&nbsp"+obj.pageNo+"&nbsp&nbsp</span>";
				//str2="<span>&nbsp共&nbsp"+obj.totalPage+"&nbsp页 &nbsp</span>";
				//$("#spage1").html("");
				//$("#spage2").html("");
				//$(str1).appendTo( $("#spage1"));
				//$(str2).appendTo( $("#spage2"));
				s_show();
			},"json");
		}
	}
	
	//跳转到微笑详情页面
	function sdetails(sid){
		$.post("../json/smileAction_detailSmile",{sid:sid},function(data){
			location.href="smile_index.jsp";
		});
	}
	

	function s_close(){
		//点击弹窗框的关闭按钮
		$(".log_user_info_del").bind({
			click:function(){
				$(".log_user").css("display","none");
				$(".log_user_info").css("display","none");
			}
		});
	}
	
	//点赞的js
	function s_show(){
		$(".smile_content_content ul li").mouseover(function(){
			$(this).children(".smile_zan").css("display","block");
		});
		
		$(".smile_content_content ul li").mouseout(function(){
			$(this).children(".smile_zan").css("display","none");
		});
		
		$(".smile_zan_zan img").bind({
			click:function(){
				var user=$("#currentUser").val();
				if( user == "" || user==null ){
					$(".log_user").css("display","block");
					$(".log_user_info").css("display","block");
				}else{
					var obj=$(this);
					var s=obj.attr("src");
					var sid=obj.attr("id");
					if(s=="images/like.ico"){
						obj.attr("src","images/no_like.ico");
						$.post("../json/smileAction_addGood",{sid:sid},function(data){
							data=parseInt($.trim(data));
							if(data==0){
								alert("由于网络原因,请稍后再试!!!");
							}
						});
					}
					else if(s=="images/no_like.ico"){
						obj.attr("src","images/like.ico");
						$.post("../json/smileAction_addGood",{sid:sid},function(data){
							data=parseInt($.trim(data));
							if(data==0){
								$(".log_user").css("display","block");
								$(".log_user_info").css("display","block");
							}
						});
					}
				}
			}
		});	
		s_close();
	}
	/**
	 * 跳转到FM页面
	 */
	function getInfo(){
		$.ajax({
			url:"../json/FmArticleAction_getDatesArticle",
			dataType:"json",
			type:"post",
			success:function(data){
				if(data!=null){
					location.href="../FM/FM_mentality.jsp";
				}
			}
		});
	}